package cn.stylefeng.guns.modular.deviceLedgerManagement.deviceLedger.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.deviceLedgerManagement.deviceLedger.entity.Equipment;
import cn.stylefeng.guns.modular.deviceLedgerManagement.deviceLedger.pojo.response.EquipmentVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.stylefeng.guns.modular.deviceLedgerManagement.deviceLedger.pojo.request.EquipmentRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 设备台账 Mapper 接口
 *
 * @author PANL
 * @since 2023/12/04 09:18
 */
public interface EquipmentMapper extends BaseMapper<Equipment> {
    /**
     * 获取自定义查询列表
     *
     * @author PANL
     * @since 2023/12/04 09:18
     */
    List<EquipmentVo> customFindList(@Param("page") Page page, @Param("param") EquipmentRequest request);

    @Update("UPDATE B_EQUIPMENT SET STATION_CODE=#{stationCode} WHERE EQP_CODE=#{eqpid}")
    void updateStation(String eqpid, String stationCode);

    @Select("SELECT EQP_CODE FROM B_EQUIPMENT WHERE STATION_CODE=#{stationCode}")
    List<String> selectStation(String stationCode);
    @Update("UPDATE B_EQUIPMENT SET STATION_CODE=null WHERE STATION_CODE=#{stationCode}")
    void updateStationToNull(String stationCode);
}
